---
category: DOM
created: '2020-04-19'
title: Scroll to top of the page
updated: '2021-10-13'
---

**JavaScript version**

```js goToTop.js
const goToTop = () => window.scrollTo(0, 0);
```

**TypeScript version**

```ts goToTop.ts
const goToTop = (): void => window.scrollTo(0, 0);
```
